#define _CRT_SECURE_NO_WARNINGS 1


    #include<math.h>
    #include<iostream>

    using namespace std;

    bool Func(long long n)
    {
        if (n == 0)
        {
            return false;
        }
        else if (n == 1)
        {
            return false;
        }
        else if (n == 2)
        {
            return false;
        }
        for (long long i = 2; i <= (long long)sqrt(n); i++)
        {
            if (n % i == 0)
            {
                return false;
            }
        }
        return true;
    }

    int main()
    {
        int t = 0;
        cin >> t;

        while (t--)
        {
            long long a = 0, b = 0;
            cin >> a >> b;

            if (Func(a * b))
            {
                cout << "YES" << endl;
            }
            else
            {
                cout << "NO" << endl;
            }
        }

        cout << sqrt(7) << endl;

        return 0;
    }